﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace msBsc.Cls
{
    public class ResourceCompress
    {
        public string MergeResourceAndCompress(string strquery)
        {
            System.Text.StringBuilder sbRet = new System.Text.StringBuilder();
            string[] arrstrteem = strquery.Split(',');
            int icount = arrstrteem.Length;
            for (int i = 0; i < arrstrteem.Length; i++)
            {
                string strfilepath = arrstrteem[i];
                //if (strfilepath.StartsWith("j_"))
                //{
                    strfilepath = CurrAppPath + "jqPlugin\\" + strfilepath.Replace("/", "\\");
                //}
                msBsc.AppLogic.Cfg.JSCompress oJSCompress = new AppLogic.Cfg.JSCompress();
                sbRet.AppendLine(oJSCompress.doCompressFromFile(strfilepath));
            }

            return sbRet.ToString();
        }


          private      string _CurrAppPath = "";
        /// <summary>
        /// 程序主目录,WEB站点目录，以\\结尾
        /// </summary>
        public string CurrAppPath
        {
            get
            {
                if (_CurrAppPath == string.Empty)
                {
                    if (HttpContext.Current == null)
                    {
                        _CurrAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                    }
                    else
                    {
                        _CurrAppPath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
                    }
                    if (!_CurrAppPath.EndsWith("\\"))
                    {
                        _CurrAppPath = _CurrAppPath + "\\";
                    }
                }
                return _CurrAppPath;
            }
        }

    }
}